package com.acane.instagram.feature.follow

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.navArgument

const val FOLLOW_ROUTE = "follow"
const val FOLLOW_ROUTE_WITH_USER_ID = "user_id"
const val FOLLOW_ROUTE_WITH_TYPE = "type" // 新增参数常量

fun NavGraphBuilder.followScreen(
    navController: NavHostController,
    toProfile: (String) -> Unit,
) {
    composable(
        route = "${FOLLOW_ROUTE}/{${FOLLOW_ROUTE_WITH_USER_ID}}/{${FOLLOW_ROUTE_WITH_TYPE}}",
        arguments = listOf(
            navArgument(FOLLOW_ROUTE_WITH_USER_ID) {
                type = NavType.StringType
            },
            navArgument(FOLLOW_ROUTE_WITH_TYPE) {
                type = NavType.StringType
                nullable = true
                defaultValue = null
            }
        )
    ) {
        FollowRoute(
            navController = navController,
            toProfile = toProfile,
        )
    }
}

fun NavController.navigateToFollow(userId: String, type: String): Unit {
    navigate("${FOLLOW_ROUTE}/$userId/$type")
}